<template>
  <div>
    <el-form :inline="true" :model="formInline" class="demo-form-inline">
      <el-form-item label="账号">
        <el-input v-model="formInline.name" placeholder="账号"></el-input>
      </el-form-item>
      <el-form-item label="密码">
        <el-input v-model="formInline.password" placeholder="密码"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="updateAdmin">确认修改</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import axios from 'axios'
export default {
  data() {
    return {
      adminData: {
        name: '',
        password: ''
      },
      formInline: {
          name: '',
          password: ''
      }
    }
  },
  created() {
    this.getAdminById(this.$route.params);
  },
  methods: {
    //通过_id获得该管理员信息
    async getAdminById(params) {
      let { data } = await axios.post('/admin/oneAdmin/',params);
      this.formInline = data[0];
    },

    async updateAdmin() {
      let data = await axios.post('/admin/updateAdmin',this.formInline);
      if(data) {
        this.$router.push('/AdminSystem1/AdminList');
      }
    }
  }
};
</script>

<style></style>
